// ---------------------------------------------------------------------------

#include <vcl.h>
#include <windows.h>
#pragma hdrstop

#include "main.h"
#include "exit.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;

// ---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) {
}

int nState = 0;

// ---------------------------------------------------------------------------
void __fastcall TMainForm::NextBtnClick(TObject *Sender) {
	switch(nState) {
	case 0: {
			ForwardBtn->Visible = true;
			BigLogoImg->Visible = false;
			TittleState1->Visible = false;
			TextState1->Visible = false;
			TopLittleShp->Visible = true;
			TittleState2->Visible = true;
			TextState2->Visible = true;
			Text2State2->Visible = true;
			LicAgree->Visible = true;
			YesRdBtn->Visible = true;
			NoRdBtn->Visible = true;
			NoRdBtn->Checked = true;
			NextBtn->Enabled = false;
			LittleLogoImg->Visible = true;
			nState = 1;
			break;
		}
	case 1: {
			LicAgree->Visible = false;
			YesRdBtn->Visible = false;
			NoRdBtn->Visible = false;
			InstDir->Visible = true;
			TittleState2->Caption = "Switch folder";
			TextState2->Caption = "Pro will be install in folder?";
			Text2State2->Caption = "Install prog in:";
			nState = 2;
			break;
		}
	case 2: {
			InstDir->Visible = false;
			InstCor->Visible = true;
			TittleState2->Caption = "All ok";
			TextState2->Caption = "Setup begin";
			Text2State2->Caption = "Correct your config:";
			InstCor->Lines->Add("Your folder:");
			InstCor->Lines->Add(InstDir->Text);
			NextBtn->Caption = "Install";
			nState = 3;
			break;
		}
	case 3: {
			InstCor->Visible = false;
			ForwardBtn->Visible = false;
			NextBtn->Visible = false;
			ProgressBar1->Visible = true;
			ProgressBar1->Position = 100;
			NextBtn->Visible = true;
			NextBtn->Caption = "Next >";
			TittleState2->Caption = "Setup go";
			TextState2->Caption = "Setup will be begin";
			Text2State2->Caption = "You can see progress:";
			CopyFile("From/Test.exe", "C:/Test.exe", false);
			nState = 4;
			break;
		}
	case 4: {
			NextBtn->Visible = false;
			ProgressBar1->Visible = false;
			TittleState2->Caption = "Finished";
			TextState2->Caption = "Gongretiletion";
			Text2State2->Caption = "Press Close button";
		}
	}
}

// ---------------------------------------------------------------------------
void __fastcall TMainForm::ForwardBtnClick(TObject *Sender) {
	switch(nState) {
	case 1: {
			TopLittleShp->Visible = false;
			TittleState2->Visible = false;
			TextState2->Visible = false;
			Text2State2->Visible = false;
			LicAgree->Visible = false;
			YesRdBtn->Visible = false;
			NoRdBtn->Visible = false;
			NextBtn->Enabled = true;
			LittleLogoImg->Visible = false;
			ForwardBtn->Visible = false;
			BigLogoImg->Visible = true;
			TittleState1->Visible = true;
			TextState1->Visible = true;
			nState = 0;
			break;
		}
	case 2: {
			InstDir->Visible = false;
			LicAgree->Visible = true;
			YesRdBtn->Visible = true;
			NoRdBtn->Visible = true;
			TittleState2->Caption = "Licensean";
			TextState2->Caption = "Read the licensea";
			Text2State2->Caption = "After read,\n click next button:";
			nState = 1;
			break;
		case 3: {
				InstCor->Visible = false;
				InstDir->Visible = true;
				TittleState2->Caption = "Switch folder";
				TextState2->Caption = "Pro will be install in folder?";
				Text2State2->Caption = "Install prog in:";
				InstCor->Lines->Clear();
				NextBtn->Caption = "Next >";
				nState = 2;
				break;
			}
		}
	default: ;
	}
}

// ---------------------------------------------------------------------------
void __fastcall TMainForm::CloseBtnClick(TObject *Sender) {
	switch(nState) {
	case 4:
		MainForm->Close();
	default:
		ExitForm->Show();
	}

}
// ---------------------------------------------------------------------------

void __fastcall TMainForm::YesRdBtnClick(TObject *Sender) {
	NextBtn->Enabled = true;
}
// ---------------------------------------------------------------------------

void __fastcall TMainForm::NoRdBtnClick(TObject *Sender) {
	NextBtn->Enabled = false;
}
// ---------------------------------------------------------------------------

